// src/modules/auth/services.ts
import axios from 'axios';

export interface LoginResponse {
    token: string;
    user: {
        username: string;
        email: string;
    };
}

export const login = async (username: string, password: string): Promise<LoginResponse> => {
    try {
        const response = await axios.post('/api/login', { username, password });
        return response.data;  // 返回 token 和用户信息
    } catch (error) {
        throw new Error('登录失败');
    }
};